package com.ghy.controller;

import com.ghy.dto.*;
import com.ghy.entity.Course;
import com.ghy.vo.SeasonSimpleListVO;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.ghy.entity.Season;
import com.ghy.service.SeasonService;

import java.util.List;

/**
 * 季次表 控制层。
 *
 * @author ghy
 * @since 2024-12-22
 */
@Tag(name = "季次")
@RestController
@RequestMapping("/season")
public class SeasonController {

    @Autowired
    private SeasonService seasonService;

    @Operation(summary ="新增——单条",description ="新增一条季次记录")
    @PostMapping("insert")
    public boolean insert(@Validated @RequestBody SeasonInsertDTO dto) {
        return seasonService.insert(dto);
    }

    @Operation(summary ="查询——单条",description ="按主键查询一条季次记录")
    @GetMapping("select/{id}")
    public Season select(@PathVariable("id") Long id) {
        return seasonService.select(id);
    }

    @Operation(summary = "查询——简单查询全部", description = "查询全部季次记录")
    @GetMapping("simpleList")
    public List<SeasonSimpleListVO> simpleList() {
        return seasonService.simpleList();
    }

    @Operation(summary ="查询——分页",description ="分页查询课程记录")
    @GetMapping("page")
    public Page<Season> page(@Validated SeasonPageDTO dto) {
        return seasonService.page(dto);
    }

    @Operation(summary="修改——单条",description="按主键修改一条课程记录")
    @PutMapping("update")
    public boolean update(@RequestBody SeasonUpdateDTO dto) {
        return seasonService.update(dto);
    }

    @Operation(summary ="删除——单条",description ="按主键删除一条课程记录")
    @DeleteMapping("delete/{id}")
    public boolean delete(@PathVariable("id") Long id) {
        return seasonService.delete(id);
    }

    @Operation(summary="删除——批量",description ="按主键批量删除课程记录")
    @DeleteMapping("deleteBatch")
    public boolean deleteBatch(@RequestParam("ids") List<Long> ids) {
        return seasonService.deleteBatch(ids);
    }

}
